package com.zaofan.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zaofan.bean.OpenBuilder;
import com.zaofan.bean.ShopBuilder;
import com.zaofan.dao.ShopBuilderDao;

public class ShopBuilderService {

	private ShopBuilderDao shopBuilderDao = new ShopBuilderDao();

	public void delete(ShopBuilder shopBuilder) {
		shopBuilderDao.del(shopBuilder);
	}

	public void add(ShopBuilder shopBuilder) {
		shopBuilderDao.add(shopBuilder);
	}

	public void update(ShopBuilder shopBuilder) {
		shopBuilderDao.update(shopBuilder);
	}

	public List<ShopBuilder> findAll(Map<String, Object> params) {
		List<ShopBuilder> data = shopBuilderDao.findAll(params);
		if (data == null) {
			data = new ArrayList<>();
		}
		return data;
	}

	public Long count(Map<String, Object> params) {
		return shopBuilderDao.count(params);
	}

	public ShopBuilder findById(Integer id) {
		Map<String, Object> params = new HashMap<>();
		params.put("id", id);
		return shopBuilderDao.findOne(params);
	}

	public void updateBuilderName(OpenBuilder openBuilder) {
		shopBuilderDao.updateBuilderName(openBuilder);
	}

	public List<ShopBuilder> findByShopId(int shopId) {
		Map<String, Object> params = new HashMap<>();
		params.put("shopId", shopId);
		return findAll(params);
	}

	public void deleteByShopId(int shopId) {
		shopBuilderDao.deleteByShopId(shopId);
	}

}
